package com.kaiwukj.android.ufamily.mvp.ui.page.service.fee;

import android.os.Bundle;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.mvp.ui.widget.SpaceItemDecoration;
import com.kaiwukj.android.ufamily.app.base.review.BaseActivity;
import com.kaiwukj.android.ufamily.app.constant.ARouterUrlKt;
import com.kaiwukj.android.ufamily.mvp.http.entity.bean.ItemOwnPayBean;
import com.kaiwukj.android.ufamily.mvp.ui.adapter.OwnPayAdapter;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

import static com.kaiwukj.android.ufamily.app.constant.ARouterUrlKt.PayFeeHomeUrl;

/**
 * @author Charles
 * @date 2019/10/15.
 * description：Kaiwu
 */
@Route(path = PayFeeHomeUrl)
public class PayFeeHomeActivity extends BaseActivity {
    /*@BindView(R.id.iv_to_property_pay)
    ImageView ivToPropertyPay;
    @BindView(R.id.iv_to_car_pay)
    ImageView ivToCarPay;
    @BindView(R.id.iv_to_car_home_pay)
    ImageView ivToCarHomePay;*/
    @BindView(R.id.qtb_view)
    QMUITopBar qtbView;
    @BindView(R.id.tv_right_nav)
    TextView tvHistory;//缴费记录

    @BindView(R.id.recycler)
    RecyclerView recyclerView;

    private QMUITipDialog hintDialog;

    /*@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_pay);
        ButterKnife.bind(this);
        initView();
    }*/


    @Override
    protected int getLayoutId() {
        return R.layout.activity_property_pay;
    }


    @Override
    protected void initView(Bundle savedInstanceState) {
        qtbView.setTitle("物业缴费");
        qtbView.addLeftBackImageButton().setOnClickListener(view -> finish());
        //ivToPropertyPay.setOnClickListener(view -> ARouter.getInstance().build(PayFeeUrl).withInt("type",1).navigation());
        //ivToCarPay.setOnClickListener(view -> showMessage("开发中"));
        //ivToCarHomePay.setOnClickListener(view -> showMessage("开发中"));

        tvHistory.setOnClickListener(v ->
                ARouter.getInstance().build(ARouterUrlKt.PayFeeHistory).navigation());


        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.addItemDecoration(new SpaceItemDecoration(8));

        List<ItemOwnPayBean> items = new ArrayList<>();
        items.add(new ItemOwnPayBean(ItemOwnPayBean.Property,
                R.drawable.bg_item_property_pay, "物业费", "线上缴费，轻松解决！"));
        items.add(new ItemOwnPayBean(ItemOwnPayBean.Car,
                R.drawable.bg_item_car_pay, "车位费", "一键缴费，畅通无阻！"));

        OwnPayAdapter mAdapter = new OwnPayAdapter(items);
        recyclerView.setAdapter(mAdapter);

        mAdapter.setOnItemClickListener((adapter, view, position) -> {
            switch (mAdapter.getType(position)) {
                case ItemOwnPayBean.Property:
                    ARouter.getInstance().build(ARouterUrlKt.PayFeeUrl)
                            .withInt("type", 1).navigation();
                    break;
                case ItemOwnPayBean.Car:
                    ARouter.getInstance().build(ARouterUrlKt.PayFeeUrl)
                            .withInt("type", 2).navigation();
                    //ToastUtils.showShort("停车费~~~");
                    break;

            }
        });
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

}
